<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>IFOnlyRT:  Fichier source de /home/digitalguru/IFOnlyRT$/IFOnlyRT/Basics/CVector3.hpp</title>
<link href="tabs.css" rel="stylesheet" type="text/css">
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Généré par Doxygen 1.5.8 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="index.html"><span>Page&nbsp;principale</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Fichiers</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>Liste&nbsp;des&nbsp;fichiers</span></a></li>
    </ul>
  </div>
<h1>/home/digitalguru/IFOnlyRT$/IFOnlyRT/Basics/CVector3.hpp</h1><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CVECTOR3_H</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CVECTOR3_H</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span><span class="comment">// Copyright (C) 2003 IFOnlyRT Project.</span>
<a name="l00004"></a>00004 
<a name="l00005"></a>00005 <span class="comment">// This program is free software: you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment">// it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment">// the Free Software Foundation, version 2.0.</span>
<a name="l00008"></a>00008 
<a name="l00009"></a>00009 <span class="comment">// This program is distributed in the hope that it will be useful,</span>
<a name="l00010"></a>00010 <span class="comment">// but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00011"></a>00011 <span class="comment">// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<a name="l00012"></a>00012 <span class="comment">// GNU General Public License 2.0 for more details.</span>
<a name="l00013"></a>00013 
<a name="l00014"></a>00014 <span class="comment">// A copy of the GPL 2.0 should have been included with the program.</span>
<a name="l00015"></a>00015 <span class="comment">// If not, see http://www.gnu.org/licenses/</span>
<a name="l00016"></a>00016 
<a name="l00017"></a>00017 <span class="comment">// Official SVN repository and contact information can be found at</span>
<a name="l00018"></a>00018 <span class="comment">// http://code.google.com/p/ifonlyrt/</span>
<a name="l00019"></a>00019 
<a name="l00020"></a>00020 <span class="comment">/*</span>
<a name="l00021"></a>00021 <span class="comment"> * CVector3.hpp</span>
<a name="l00022"></a>00022 <span class="comment"> *</span>
<a name="l00023"></a>00023 <span class="comment"> *  Created on: 15 oct. 2009</span>
<a name="l00024"></a>00024 <span class="comment"> *      Author: Maxime Gaudin</span>
<a name="l00025"></a>00025 <span class="comment"> */</span>
<a name="l00026"></a>00026 
<a name="l00027"></a>00027 <span class="preprocessor">#include &lt;iostream&gt;</span>
<a name="l00028"></a>00028 <span class="preprocessor">#include &lt;string&gt;</span>
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 <span class="preprocessor">#ifndef UINT</span>
<a name="l00031"></a>00031 <span class="preprocessor"></span>        <span class="keyword">typedef</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> uint;
<a name="l00032"></a>00032 <span class="preprocessor">        #define UINT</span>
<a name="l00033"></a>00033 <span class="preprocessor"></span><span class="preprocessor">#endif</span>
<a name="l00034"></a>00034 <span class="preprocessor"></span>
<a name="l00038"></a>00038 <span class="keyword">template</span> &lt;<span class="keyword">class</span> T&gt;
<a name="l00039"></a><a class="code" href="classNumbersOnly.html">00039</a> <span class="keyword">class </span><a class="code" href="classNumbersOnly.html">NumbersOnly</a>
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041         <span class="keyword">private</span>:
<a name="l00042"></a>00042                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">int</span>&amp;                            i )<span class="keyword"> const</span>{ }
<a name="l00043"></a>00043                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> uint&amp;                           i )<span class="keyword"> const</span>{ }
<a name="l00044"></a>00044                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">char</span>&amp;                           i)<span class="keyword"> const</span>{ }
<a name="l00045"></a>00045                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>&amp;          i)<span class="keyword"> const</span>{ }
<a name="l00046"></a>00046 
<a name="l00047"></a>00047                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">double</span>&amp;                         i)<span class="keyword"> const</span>{ }
<a name="l00048"></a>00048                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">long</span>&amp;                           i)<span class="keyword"> const</span>{ }
<a name="l00049"></a>00049                 <span class="keywordtype">void</span> ValidateType(<span class="keyword">const</span> <span class="keywordtype">float</span>&amp;                          i)<span class="keyword"> const</span>{ }
<a name="l00050"></a>00050 
<a name="l00051"></a>00051         <span class="keyword">public</span>:
<a name="l00052"></a>00052                 <a class="code" href="classNumbersOnly.html">NumbersOnly</a>()
<a name="l00053"></a>00053             {
<a name="l00054"></a>00054                T valid;
<a name="l00055"></a>00055                ValidateType(valid);
<a name="l00056"></a>00056             };
<a name="l00057"></a>00057 };
<a name="l00058"></a>00058 
<a name="l00063"></a>00063 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T = <span class="keywordtype">double</span>&gt;
<a name="l00064"></a><a class="code" href="classCVector3.html">00064</a> <span class="keyword">class </span><a class="code" href="classCVector3.html">CVector3</a> {
<a name="l00065"></a>00065         <span class="keyword">public</span>:
<a name="l00070"></a><a class="code" href="classCVector3.html#fac1fcff64f6a7c5612ef2bd9bd535f9">00070</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#fac1fcff64f6a7c5612ef2bd9bd535f9">Zero</a>;
<a name="l00071"></a>00071 
<a name="l00076"></a><a class="code" href="classCVector3.html#844ef850195b17898fb752f23feb0a0d">00076</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#844ef850195b17898fb752f23feb0a0d">One</a>;
<a name="l00077"></a>00077 
<a name="l00082"></a><a class="code" href="classCVector3.html#4fef05680b949988a5075c6c41086ae7">00082</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#4fef05680b949988a5075c6c41086ae7">Up</a>;
<a name="l00083"></a>00083 
<a name="l00088"></a><a class="code" href="classCVector3.html#57ba7ab54ac4902dd8b63f780c8cfafc">00088</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#57ba7ab54ac4902dd8b63f780c8cfafc">Down</a>;
<a name="l00089"></a>00089 
<a name="l00094"></a><a class="code" href="classCVector3.html#870850d3d034e6b45576231f6fded344">00094</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#870850d3d034e6b45576231f6fded344">Right</a>;
<a name="l00095"></a>00095 
<a name="l00100"></a><a class="code" href="classCVector3.html#ab63e58f3017193d71f893c9ad44ff51">00100</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#ab63e58f3017193d71f893c9ad44ff51">Left</a>;
<a name="l00101"></a>00101 
<a name="l00106"></a><a class="code" href="classCVector3.html#1a32fc8263e25eacc62863d2c32b92a0">00106</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#1a32fc8263e25eacc62863d2c32b92a0">Backward</a>;
<a name="l00107"></a>00107 
<a name="l00112"></a><a class="code" href="classCVector3.html#62b7622b7c881e5046b564968ef0412b">00112</a>                 <span class="keyword">static</span> <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#62b7622b7c881e5046b564968ef0412b">Forward</a>;
<a name="l00113"></a>00113 
<a name="l00114"></a>00114         <span class="keyword">public</span>:
<a name="l00119"></a>00119                 <a class="code" href="classCVector3.html#4740c9cde35c5c474929011e887f3ca2">CVector3</a>();
<a name="l00120"></a>00120 
<a name="l00124"></a>00124                 <a class="code" href="classCVector3.html#4740c9cde35c5c474929011e887f3ca2">CVector3</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; Copy);
<a name="l00125"></a>00125 
<a name="l00132"></a>00132                 <a class="code" href="classCVector3.html#4740c9cde35c5c474929011e887f3ca2">CVector3</a>(<span class="keyword">const</span> T&amp; vX, <span class="keyword">const</span> T&amp; vY, <span class="keyword">const</span> T&amp; vZ);
<a name="l00133"></a>00133 
<a name="l00138"></a>00138                 <a class="code" href="classCVector3.html#4740c9cde35c5c474929011e887f3ca2">CVector3</a>(<span class="keyword">const</span> T&amp; Value);
<a name="l00139"></a>00139 
<a name="l00140"></a>00140         <span class="keyword">public</span>:
<a name="l00145"></a>00145                 T                               <a class="code" href="classCVector3.html#48a57f88bbb3a87da14d82e5ccba47a9">GetModulus</a>() <span class="keyword">const</span>;
<a name="l00146"></a>00146 
<a name="l00152"></a>00152                 T                               <a class="code" href="classCVector3.html#576862e3ee36b568d55d4e713fa775a1">GetSquaredModulus</a>() <span class="keyword">const</span>;
<a name="l00153"></a>00153 
<a name="l00158"></a>00158                 <span class="keywordtype">void</span>                    <a class="code" href="classCVector3.html#f79a62e6e495a1121ca543876ae349b2">Normalize</a>();
<a name="l00159"></a>00159 
<a name="l00163"></a>00163                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>     <a class="code" href="classCVector3.html#073aaaf794234d29ec4469aaf2899b9a">GetNormalized</a>() <span class="keyword">const</span>;
<a name="l00164"></a>00164 
<a name="l00165"></a>00165         <span class="keyword">public</span>:
<a name="l00171"></a><a class="code" href="classCVector3.html#2730d6a7271a74f8b2df0699d1088a44">00171</a>                 <span class="keyword">static</span> T <a class="code" href="classCVector3.html#2730d6a7271a74f8b2df0699d1088a44">Dot</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2)
<a name="l00172"></a>00172                 { <span class="keywordflow">return</span> V1.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a> * V2.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a> + V1.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a> * V2.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a> + V1.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a> * V2.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a>; }
<a name="l00178"></a><a class="code" href="classCVector3.html#c3d5abf340dff1688b48f104e9a85159">00178</a>                 <span class="keyword">static</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#c3d5abf340dff1688b48f104e9a85159">Cross</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2)
<a name="l00179"></a>00179                 {
<a name="l00180"></a>00180                         <span class="keywordflow">return</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>(     V1.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a> * V2.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a> - V1.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a> * V2.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a>
<a name="l00181"></a>00181                                                                 , V1.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a> * V2.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a> - V1.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a> * V2.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a>
<a name="l00182"></a>00182                                                                 , V1.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a> * V2.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a> - V1.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a> * V2.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a>);
<a name="l00183"></a>00183                 }
<a name="l00184"></a>00184 
<a name="l00185"></a>00185         <span class="keyword">public</span>:
<a name="l00190"></a>00190                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#8294b145ea7ea613bc17c7eec8fcc3db">operator =</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2);
<a name="l00191"></a>00191 
<a name="l00196"></a>00196                 T <a class="code" href="classCVector3.html#0df9aafb0012dcea4a941bc485952a4d">operator []</a>(<span class="keyword">const</span> uint i);
<a name="l00197"></a>00197 
<a name="l00202"></a>00202                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#b9d4271e795f10a73ba8042dd2e48dc6">operator +</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2);
<a name="l00203"></a>00203 
<a name="l00208"></a>00208                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#b0bec4d678c5047f4f72ad4b456a5a9f">operator +=</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2);
<a name="l00209"></a>00209 
<a name="l00214"></a>00214                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#5b0e9f003868a8c59e8e3958f6dd4fe8">operator -</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2);
<a name="l00215"></a>00215 
<a name="l00220"></a>00220                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#396f876070b0ffc6a31613f3ed45d81d">operator -=</a>(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V2);
<a name="l00221"></a>00221 
<a name="l00226"></a>00226                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#56883c2cdb79845f2db40cf918ac66da">operator *</a>(<span class="keyword">const</span> T Scalar);
<a name="l00227"></a>00227 
<a name="l00232"></a>00232                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#5583f9011e8b75b4e180beda68efa06b">operator *=</a>(<span class="keyword">const</span> T Scalar);
<a name="l00233"></a>00233 
<a name="l00238"></a>00238                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#8950ff13ec313f85456a86e06d3db8a0">operator /</a>(<span class="keyword">const</span> T Scalar);
<a name="l00239"></a>00239 
<a name="l00244"></a>00244                 <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a> <a class="code" href="classCVector3.html#49db160dad2721bca2ff8035b20fea7c">operator /=</a>(<span class="keyword">const</span> T Scalar);
<a name="l00245"></a>00245 
<a name="l00246"></a>00246         <span class="keyword">public</span>:
<a name="l00251"></a><a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">00251</a>                 T <a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a>;
<a name="l00252"></a>00252 
<a name="l00257"></a><a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">00257</a>                 T <a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a>;
<a name="l00258"></a>00258 
<a name="l00263"></a><a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">00263</a>                 T <a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a>;
<a name="l00264"></a>00264 };
<a name="l00265"></a>00265 
<a name="l00270"></a>00270 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;
<a name="l00271"></a>00271 <span class="keywordtype">bool</span> operator ==(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;U&gt;</a>&amp; V2)
<a name="l00272"></a>00272 {
<a name="l00273"></a>00273         <span class="keywordflow">if</span>(V1.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a> != V2.<a class="code" href="classCVector3.html#f18052d81703ad55a02e60ba27107609">X</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00274"></a>00274         <span class="keywordflow">if</span>(V1.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a> != V2.<a class="code" href="classCVector3.html#495f66ef3296e4be2155db06cb7c8f43">Y</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00275"></a>00275         <span class="keywordflow">if</span>(V1.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a> != V2.<a class="code" href="classCVector3.html#150b38796ffb943e073f266c9bf52b61">Z</a>) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00276"></a>00276 
<a name="l00277"></a>00277         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00278"></a>00278 }
<a name="l00279"></a>00279 
<a name="l00284"></a>00284 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> U&gt;
<a name="l00285"></a>00285 <span class="keywordtype">bool</span> operator !=(<span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;T&gt;</a>&amp; V1, <span class="keyword">const</span> <a class="code" href="classCVector3.html">CVector3&lt;U&gt;</a>&amp; V2)
<a name="l00286"></a>00286 {
<a name="l00287"></a>00287         <span class="keywordflow">return</span> !(V1 == V2);
<a name="l00288"></a>00288 }
<a name="l00289"></a>00289 
<a name="l00294"></a>00294 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T&gt;
<a name="l00295"></a>00295 std::ostream&amp; operator&lt;&lt;(std::ostream&amp; outStream,const CVector3&lt;T&gt;&amp; V1)
<a name="l00296"></a>00296 {
<a name="l00297"></a>00297         outStream &lt;&lt; std::string(<span class="stringliteral">"{X = "</span>);
<a name="l00298"></a>00298         outStream &lt;&lt; V1.X &lt;&lt; <span class="stringliteral">", Y = "</span>;
<a name="l00299"></a>00299         outStream &lt;&lt; V1.Y &lt;&lt; <span class="stringliteral">", Z = "</span>;
<a name="l00300"></a>00300         outStream &lt;&lt; V1.Z &lt;&lt; <span class="stringliteral">", Length = "</span>;
<a name="l00301"></a>00301         outStream &lt;&lt; V1.GetModulus() &lt;&lt; <span class="stringliteral">"}"</span>;
<a name="l00302"></a>00302         <span class="keywordflow">return</span> outStream;
<a name="l00303"></a>00303 }
<a name="l00304"></a>00304 <span class="preprocessor">#endif </span><span class="comment">/* CVECTOR3_H */</span>
<a name="l00305"></a>00305 
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Généré le Thu Oct 22 19:37:51 2009 pour IFOnlyRT par&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.8 </small></address>
</body>
</html>
